<?php
class DbError extends Exception
{
    public $code = 0;
    // Die Exceptionmitteilung neu definieren, damit diese nicht optional ist
    public function __construct($message,$sql, $code = 0) {
        // etwas Code
        $this->code = $code;
        
        $log_dir = $_SERVER['DOCUMENT_ROOT'].ConfigFile::Get('BASE_DIR')."/logs/";
        // file container where all texts are to be written
        $fileContainer = 'Db_'.date("MjY").'.log';
        // open the said file
        $filePointer = fopen($log_dir.$fileContainer,"w+");
        
        // text to be written in the file
        $logMsg =  date("H:i")." --- $code ---  $message --- $sql \n";
        
        $log = file_get_contents($log_dir.$fileContainer);
        $logMsg = $log.$logMsg;
        
        // below is where the log message has been written to a file.
        fputs($filePointer,$logMsg);
        
        // close the open said file after writing the text
        fclose($filePointer);

        // sicherstellen, dass alles korrekt zugewiesen wird
        parent::__construct($message, $code);
    }

    // maßgeschneiderte Stringdarstellung des Objektes
    public function __toString() {
        
    }
}
?>